import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class ListPageState {
  @JsonKey(name: 'blocks')
  List<Blocks> blocks;
  ListPageState(
    this.blocks,
  );
  //根据 json 创建对象
  factory ListPageState.fromJson(Map<String, dynamic> srcJson) =>
      _$ListPageStateFromJson(srcJson);
}

ListPageState _$ListPageStateFromJson(Map<String, dynamic> json) =>
    ListPageState((json['blocks'] as List<dynamic>)
        .map((e) => Blocks.fromJson(e as Map<String, dynamic>))
        .toList());

class Blocks extends Object {
  late String blockCode;
  late String showType;

  Blocks(
    this.blockCode,
    this.showType,
  );

  factory Blocks.fromJson(Map<String, dynamic> srcJson) =>
      _$BlocksFromJson(srcJson);

  Blocks? elementAt(int index) {}
}

Blocks _$BlocksFromJson(Map<String, dynamic> json) => Blocks(
      json['blockCode'] as String,
      json['showType'] as String,
    );
